package com.atguigu.feign.controller;


import com.atguigu.common.CommonResult;
import com.atguigu.entity.Payment;

import com.atguigu.feign.config.ProviderClient;
import com.netflix.discovery.converters.Auto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class FeignController {
    @Autowired
    ProviderClient providerClient;


    @GetMapping("selectAll/{id}")

    public CommonResult<Payment> select(@PathVariable Long id) {
        CommonResult<Payment> commonResult = providerClient.selectById(id);
        return commonResult;
    }

    @GetMapping( "/consumer/payment/feign/timeout")
    public String paymentFeignTimeout() {
        // OpenFeign客户端一般默认等待1秒钟
        log.info("运行了");
        return providerClient.paymentFeignTimeout();

    }
}
